package xsdcl;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import xsdcl.NodeClassifier.EdgeClasses;

public class TreeEdge
{
	private EdgeClasses edgeClass; // IDD or IRT
	private List<TreeNode> nodes;
	private Set<String> nodeNames;
	private String name;
	private List<TreeNode> rocList; // Related Object Classes
	private List<TreeNode> raList; // Relationship Attributes

	public TreeEdge(List<TreeNode> nodes)
	{
		nodeNames = new HashSet<String>();
		this.nodes = nodes;
		name = new String();
		name = "";
		for (TreeNode node : nodes)
		{
			name = name + node.getName() + "_";
			nodeNames.add(node.getName());
		}
		name = name.substring(0, name.length() - 1);
		rocList = new ArrayList<TreeNode>();
		raList = new ArrayList<TreeNode>();
	}

	public void addROC(TreeNode rocNode)
	{
		rocList.add(rocNode);
	}

	public void addRA(TreeNode raNode)
	{
		raList.add(raNode);
	}

	public List<TreeNode> getROCList()
	{
		return rocList;
	}

	public List<TreeNode> getRAList()
	{
		return raList;
	}

	public List<TreeNode> getNodes()
	{
		return nodes;
	}

	public void setNodes(List<TreeNode> nodes)
	{
		this.nodes = nodes;
	}

	public String getName()
	{
		return name;
	}

	public EdgeClasses getEdgeClass()
	{
		return edgeClass;
	}

	public void setEdgeClass(EdgeClasses edgeClass)
	{
		this.edgeClass = edgeClass;

	}

	public Set<String> getNodeNames()
	{
		return nodeNames;
	}
	

	public void setROCList(List<TreeNode> rocList)
	{
		this.rocList = rocList;
	}

	
	public void setRAList(List<TreeNode> raList)
	{
		this.raList = raList;
	}
	


	@Override
	public boolean equals(Object obj)
	{
		if (obj instanceof TreeEdge)
		{
			TreeEdge other = (TreeEdge) obj;
			// if (other.getNodeNames().equals(this.getNodeNames()))
			if (other.getNodes().containsAll(this.getNodes())
					&& this.getNodes().containsAll(other.getNodes()))
			{
				return true;
			}
		}
		return false;
	}

}
